package com.wq.myspring.eventmode;

/**
 * @PackageName: com.wq.myspring.eventmode
 * @ClassName EventListener
 * @Description: TODO 事件监听器
 * @Author Wenqiang
 * @Date 2021/07/18 0:29
 * @Version V1.0
 */
public abstract class EventListener {
	public EventSource eventSource;
	abstract void eventProcess(Event e);
}

class SimpleEventListener extends EventListener {
	//private EventSource eventSource;
	public SimpleEventListener(EventSource eventSource) {
		this.eventSource = eventSource;
		eventSource.register(this);
	}

	@Override
	public void eventProcess(Event e) {
		if("simpleEvent".equals(e.getType())){
			System.out.println("simpleEvent 事件处理---------------------");
		}
	}
}

class ComplexEventListener extends EventListener {

	//private EventSource eventSource;
	public ComplexEventListener(EventSource eventSource) {
		this.eventSource = eventSource;
		eventSource.register(this);
	}

	@Override
	public void eventProcess(Event e) {
		if("complexEvent".equals(e.getType())){
			System.out.println("complexEvent 事件处理---------------------");
		}
	}
}

/*
class ComplexEventListener ex EventListener {
	@Override
	public void eventProcess(Event e) {
		if("complexEvent".equals(e.getType())){
			System.out.println("complexEvent 事件处理---------------------");
		}
	}
}*/
